import { httpCreate, CommonResponse } from './http';
const http = httpCreate('/srv/order');

export const order = {
	getOrderList<T>(params: {
		pageNum: number;
		pageSize: number;
		userSearchText?: number | string;
		startTime?: number | string;
		endTime?: number | string;
	}) {
		return http.post<T, CommonResponse>('license-record/order/list', {}, { params });
	},
	// 详情-付费记录
	getDetalsPayRecords<T>(params: {
		pageNum: number;
		pageSize: number;
		userSearchText?: number | string;
		startTime?: number;
		endTime?: number;
	}) {
		return http.post<T, CommonResponse>('/license-record/list', {}, { params });
	},
	// 详情-付费记录-新
	getNewPayRecords<T>(userId: number) {
		return http.get<T, CommonResponse>(`/license-record/payedList/${userId}`);
	},
	// 开票记录
	getInvoiceRecords<T>(
		invoiceStatus: number,
		params: {
			pageNum: number;
			pageSize: number;
			startTime?: number | string;
			endTime?: number | string;
			userSearchText?: number | string;
			phone?: number;
		}
	) {
		return http.get<T, CommonResponse>(`/invoiceContent/list/${invoiceStatus}`, { params });
	},
	// 开票
	invoicing<T>(body: { id: number; expressCompany?: string; expressNo?: number }) {
		return http.post<T, CommonResponse>('/invoiceContent/record/generate', body);
	},
	// 审核列表
	getLicenseRecord<T>(params: {
		pageNum: number;
		pageSize: number;
		userSearchText?: number | string;
		startTime?: number | string;
		endTime?: number | string;
	}) {
		return http.post<T, CommonResponse>('/license-record/list', {}, { params });
	},
	// 撤销授权
	cancelAuth<T>(id: number) {
		return http.post<T, CommonResponse>(`/license-record/repeal/${id}`);
	},
	// 修改备注
	updateRemark<T>(
		id: number,
		body: {
			remark: string;
		}
	) {
		return http.put<T, CommonResponse>(`/license-record/remark/${id}`, body);
	},
	// 用户管理-授权-授权类型
	getPriceList<T>(body: Array<number>) {
		return http.post<T, CommonResponse>('/price/list', body);
	},
	// 查询付款公司
	getPayCompany<T>(payMode: number) {
		return http.get<T, CommonResponse>(`/pay-mode-company/${payMode}`);
	},
	// 新增授权
	addAuth<T>(body: {
		userId: number;
		licenseType: number;
		amount: number;
		paymentMode: number;
		payModeCompany: number;
		remark: string;
		evidence: string;
		account: number;
		payDate: number;
		dueDate?: number;
	}) {
		return http.post<T, CommonResponse>('/license-record/add', body);
	},
	// 开票记录详情
	getInvoiceDetails<T>(id: number) {
		return http.get<T, CommonResponse>(`/invoiceContent/record/info/${id}`);
	},
	// 获取是否已经7天授权
	getHasPower<T>(userId: number) {
		return http.get<T, CommonResponse>(`/license-record/isTestService/${userId}`);
	},
};
